﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExceptionHandling
{
    class Program
    {
        static void NumberRangeCheck(int minValue, int maxValue)
        {
            Console.Write("enter number from {0} to {1}: ", minValue, maxValue);
            int num = int.Parse(Console.ReadLine());
            if ((num < minValue) || (num > maxValue))
            {
                throw new InvalidRangeException<int>(minValue, maxValue);
            }
            else
            {
                Console.WriteLine("number {0} is in range {1} - {2}", num, minValue, maxValue);
            }
        }


        static void Main(string[] args)
        {
            Console.Write("enter min value: ");
            int minVal = int.Parse(Console.ReadLine());
            Console.Write("enter max value: ");
            int maxVal = int.Parse(Console.ReadLine());
            for (int i = 0; i < 5; i++)
            {
                //try
                //{
                    NumberRangeCheck(minVal, maxVal);
                //}
                //catch
                //{
                //    Console.WriteLine("number is outside {0} - {1} range", minVal, maxVal);
                //}
            }
        }
    }
}
